<?php
/* [$WindsForce] (C)Hunzhiwange.COM Since 2014.07.14.
   家居公司套餐显示($$)*/

!defined('Q_PATH') && exit;

class Packageshow_C_Controller extends InitController{

	public function index(){
		$arrJiajucompany=$this->_oParent->_arrJiajucompany;
		$nId=intval(Q::G('id','G'));

		if(!$nId){
			$this->page404();
		}

		// 套餐显示
		$arrWhere=array();
		$arrWhere['A.jiajupackage_status']=1;
		$arrWhere['A.jiajupackage_id']=$nId;
		$arrWhere['A.jiajucompany_id']=$arrJiajucompany['jiajucompany_id'];

		$arrPackage=Model::F_('jiajupackage','@A')
			->setColumns('A.jiajupackage_id,A.jiajupackage_title,A.jiajupackage_price,A.jiajupackage_firstprice,A.jiajupackage_default,A.jiajupackage_intro,A.jiajupackage_viewnum')
			->join(Q::C('DB_PREFIX').'jiajupackagecontent AS B','B.jiajupackage_content','A.jiajupackage_id=B.jiajupackage_id')
			->where($arrWhere)
			->getOne();

		if(empty($arrPackage['jiajupackage_id'])){
			$this->page404();
		}

		// 更新点击量
		Model::M_('jiajupackage')->updateWhere(array('jiajupackage_viewnum'=>$arrPackage['jiajupackage_viewnum']+1),'jiajupackage_id=?',$nId);
		$arrPackage['jiajupackage_viewnum']++;

		Core_Extend::getSeo($this,array(
			'title'=>"{$arrPackage['jiajupackage_title']}家装套餐",
			'keywords'=>"{$arrPackage['jiajupackage_title']}套餐,{$arrPackage['jiajupackage_title']}套餐价格,{$arrPackage['jiajupackage_title']}套餐折扣",
			'description'=>"通过{$GLOBALS['_option_']['site_name']}预订{$arrJiajucompany['jiajucompany_fullname']}原价{$arrPackage['jiajupackage_price']}元/平米{$arrPackage['jiajupackage_title']}精品家装套餐，现在仅需{$arrPackage['jiajupackage_firstprice']}元/平米。",
		));

		$this->assign('arrPackage',$arrPackage);
		$this->assign('arrConfigTitle',json_decode($GLOBALS['_cache_']['jiaju_option']['package_config'],true));
		$this->assign('arrConfigData',json_decode($arrPackage['jiajupackage_content'],true));
		$this->display(Jiaju_Extend::getTemplate($arrJiajucompany,'packageshow'));
	}

}
